package com.yanqu.road.server.cmd.activity.ghost;

import com.yanqu.road.logic.pb.GhostPb;
import com.yanqu.road.pb.activity.GhostActivityProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.cross.battle.ghost.GhostActivity;
import com.yanqu.road.server.manager.cross.battle.ghost.GhostMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;

@Cmd(code = CrossProtocol.C2_GHOST_ACTIVITY_QUIT_BOSS_ROOM, desc = "退出boss房间")
public class CrossGhostQuitBossRoomCmd extends CrossCommand {

    int activityId;
    GhostActivityProto.GhostSimplePlayerMsg playerData;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        GhostActivityProto.CrossQuitBossRoomReqMsg reqMsg = GhostActivityProto.CrossQuitBossRoomReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        playerData = reqMsg.getPlayerData();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        GhostActivity activity = GhostMgr.getActivity(activityId);
        if (activity == null) {
            ret = GameErrorCode.E_GHOST_ACTIVITY_NO_OPEN;
            return;
        }

        // 退出房间
        activity.quitRoom(GhostPb.parseGhostSimplePlayer(playerData));
    }

    @Override
    public void sendData() {

    }
}
